<style>
    .input-notice {
        color: #4e73df;
        margin-top: 5px;
        display: block;
    }

    .select-hide{
        display: none;
    }
</style>
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">优惠码</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-value" class="form-control" name="row[value]" value="{$row.value|htmlentities}" type="text" placeholder="字母与数字组合">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">优惠类型</label>
        <div class="col-xs-12 col-sm-8">
            {:build_radios('row[type]', [0=>'百分比', 1=>'固定金额'], $row.type)}
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">折扣</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-discount" class="form-control" name="row[discount]" value="{$row.discount|htmlentities}" type="text" placeholder="百分比和固定金额折扣都应填入数字">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">只能使用一次</label>
        <div class="col-xs-12 col-sm-8">
            <input  id="c-single" name="row[single]" type="hidden" value="{$row.single}">
            <a href="javascript:;" data-toggle="switcher" class="btn-switcher" data-input-id="c-single" data-yes="1" data-no="0" >
                <i class="fa fa-toggle-on text-success {eq name="$row.single" value="0"}fa-flip-horizontal text-gray{/eq} fa-2x"></i>
            </a>
            <span class="input-notice">一个用户只能使用一次，游客不能使用</span>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">最大使用次数</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-max_use" class="form-control" name="row[max_use]" value="{$row.max_use|htmlentities}" type="text" placeholder="为空则不限制使用次数">
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">过期时间</label>
        <div class="col-xs-12 col-sm-8">
            <input placeholder="选择优惠券的失效时间，留空则长期有效" id="c-expire_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[expire_time]" type="text" value="{:empty($row.expire_time) ? '' : date('Y-m-d H:i:s',$row.expire_time)}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">适用于</label>
        <div class="col-xs-12 col-sm-8">
            {:build_radios('row[apply]', [0=>'全站通用', 1=>'分类', 2=>'商品'], $row.apply)}
        </div>
    </div>
    <div class="form-group select-category {:$row.apply == 0 || $row.apply == 2 ? 'select-hide' : ''}">
        <label class="control-label col-xs-12 col-sm-2">选择分类</label>
        <div class="col-xs-12 col-sm-8">
            <div class="checkbox">
                {volist name="category" id="vo"}
                <label><input name="row[category_ids][]" type="checkbox" value="{$vo.id}" {:in_array($vo.id, explode(',',$row.category_ids)) ? 'checked' : ''}>{$vo.name}</label>
                {/volist}
            </div>
        </div>
    </div>
    <div class="form-group select-goods {:$row.apply == 0 || $row.apply == 1 ? 'select-hide' : ''}">
        <label class="control-label col-xs-12 col-sm-2">选择商品</label>
        <div class="col-xs-12 col-sm-8">
            <div class="checkbox">
                {volist name="$goods" id="vo"}
                <label><input name="row[goods_ids][]" type="checkbox" value="{$vo.id}" {:in_array($vo.id, explode(',',$row.goods_ids)) ? 'checked' : ''}>{$vo.name}</label>
                {/volist}
            </div>
        </div>
    </div>
    <div class="form-group">
        <label for="c-remark" class="control-label col-xs-12 col-sm-2">备注</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-remark" class="form-control" name="row[remark]">{$row.remark}</textarea>
        </div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>

